<template>
  <div class="mod-config">
    <basic-container>
      <navigationRenWuShu
        :sign="{ a: true, b: false, c: false, d: false, e: false, f: false }"
      ></navigationRenWuShu>
      <div class="boxsty zhiBiao">
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
              label-width="110px"
            >
              <el-form-item label="任务书名称">
                <el-input
                  style="width: 150px"
                  v-model="dataForm.workAssignName"
                  placeholder="任务书名称"
                  :clearable="true"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人姓名">
                <el-input
                  style="width: 150px"
                  v-model="dataForm.ryName"
                  placeholder="被考核人姓名"
                  :clearable="true"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人岗位">
                <el-input
                  style="width: 150px"
                  v-model="dataForm.userZw"
                  placeholder="被考核人岗位"
                  :clearable="true"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人职级">
                <el-input
                  style="width: 150px"
                  v-model="dataForm.userZj"
                  placeholder="被考核人职级"
                  :clearable="true"
                ></el-input>
              </el-form-item>
              <el-form-item label="任务书状态">
                <el-select
                  style="width: 150px"
                  v-model="dataForm.state"
                  placeholder="请选择"
                  clearable
                >
                  <el-option value="" label="全部"></el-option>
                  <el-option value="0" label="创建中"></el-option>
                  <el-option value="1" label="填报中"></el-option>
                  <el-option value="2" label="审核中"></el-option>
                  <el-option value="3" label="已结束"></el-option>
                  <el-option value="4" label="被考人驳回"></el-option>
                  <el-option value="5" label="汇总完成"></el-option>
                  <el-option value="6" label="汇总驳回"></el-option>
                  <el-option value="7" label="文本审核中"></el-option>
                  <el-option value="8" label="文本审核驳回"></el-option>
                  <el-option value="9" label="文本审核完成"></el-option>
                  <el-option value="10" label="被考核人审核中"></el-option>
                  <el-option value="11" label="被考核人驳回"></el-option>
                  <el-option value="12" label="被考核人审核完成"></el-option>
                  <el-option value="13" label="履约中"></el-option>
                  <el-option value="14" label="自评中"></el-option>
                  <el-option value="15" label="评价中"></el-option>
                  <el-option value="16" label="他评完成"></el-option>
                  <el-option value="17" label="结果汇总中"></el-option>
                  <el-option value="18" label="领导审核中"></el-option>
                  <el-option value="19" label="领导审核完成"></el-option>
                  <el-option value="20" label="审核结束"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList()"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div style="height: 50px; border-bottom: 1px solid #b0bde2">
          <el-tooltip
            class="item"
            effect="dark"
            content="导入一个任务书"
            placement="top"
          >
            <el-button
              icon="el-icon-upload"
              size="small"
              type="success"
              circle
              @click="openImport"
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="下载任务书模板"
            placement="top"
          >
            <el-button
              icon="el-icon-download"
              size="small"
              type="warning"
              circle
              @click="exportWord"
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="新增一个任务书"
            placement="top"
            v-model="isShow"
          >
            <el-button
              icon="el-icon-plus"
              type="primary"
              v-if="permissions.hetongrenwu_hetonghtxxdjb_add"
              @click="addOrUpdateHandle()"
              circle
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="打印一个任务书"
            placement="top-start"
          >
            <el-button
              type="info"
              icon="el-icon-printer"
              @click="print()"
              circle
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="批量删除选中的任务书"
            placement="top-start"
          >
            <el-button
              type="danger"
              icon="el-icon-delete"
              @click="deleteBatch()"
              circle
            ></el-button>
          </el-tooltip>
          <div class="pull-right">
            <el-button
              type="primary"
              plain
              @click="ndts()"
              v-loading.fullscreen.lock="fullscreenLoadingnd"
              >拟定推送</el-button
            >
            <el-button
              type="primary"
              plain
              @click="getHtWeight()"
              v-loading.fullscreen.lock="fullscreenLoadingwb"
              >推送文本</el-button
            >
            <el-button
              plain
              type="primary"
              v-loading.fullscreen.lock="fullscreenLoadingwb"
              @click="FqqdBtn"
              >发起签订</el-button
            >
          </div>
        </div>
        <div class="avue-crud">
          <el-table
            ref="table"
            style="width: 100%; margin-top: 20px"
            :data="dataList"
            border
            v-loading="dataListLoading"
            v-if="rednermsg"
          >
            <el-table-column
              type="selection"
              width="55"
              header-align="center"
              align="center"
            ></el-table-column>
            <el-table-column
              type="index"
              width="60"
              header-align="center"
              align="center"
              label="序号"
            ></el-table-column>
            <el-table-column
              prop="workAssignName"
              header-align="center"
              align="center"
              width="160"
              show-overflow-tooltip
              label="任务书名称"
            >
              <template slot-scope="scope">
                <span
                  @click="editBtn(scope.row)"
                  style="color: #0e258c; cursor: pointer"
                  >{{ scope.row.workAssignName }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              prop="userName"
              header-align="center"
              align="center"
              min-width="150"
              label="被考核人编号"
            >
            </el-table-column>
            <el-table-column
              prop="ryName"
              header-align="center"
              align="center"
              min-width="150"
              label="被考核人姓名"
            >
            </el-table-column>
            <el-table-column
              prop="userDeptName"
              header-align="center"
              align="center"
              min-width="150"
              label="被考核人单位"
              show-overflow-tooltip
            >
            </el-table-column>
            <el-table-column
              prop="userZw"
              header-align="center"
              align="center"
              min-width="170"
              label="被考核人岗位"
              show-overflow-tooltip
            >
            </el-table-column>
            <!-- <el-table-column
              prop="userZj"
              header-align="center"
              align="center"
              min-width="170"
              label="被考核人职级"
            > -->
            </el-table-column>
            <el-table-column
              prop="weight"
              header-align="center"
              align="center"
              min-width="60"
              label="权重"
            >
              <template slot-scope="scope">
                <span
                  :style="{ color: scope.row.weight !== '100' ? 'red' : '' }"
                  >{{ scope.row.weight }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              prop="quotaauditStatus"
              header-align="center"
              align="center"
              min-width="120"
              label="指标审核状态"
            >
              <template slot-scope="scope">
                <el-popover placement="top" width="240" trigger="hover">
                  <p></p>
                  <div
                    v-for="(item, index) in cutout(
                      scope.row.quotaauditStatusstr
                    )"
                    :key="index"
                  >
                    <el-badge
                      v-if="scope.row.quotaauditStatus != '0'"
                      :value="item.split('-')[1]"
                      :max="9"
                      class="itembadge"
                    >
                      <span
                        v-if="item.indexOf('已完成') != -1"
                        style="color: #0bbf4a"
                        >{{ item.split("-")[0] }}</span
                      >
                      <span
                        v-else-if="item.indexOf('未完成') != -1"
                        style="color: red"
                        >{{ item.split("-")[0] }}</span
                      >
                      <span v-else>{{ item.split("-")[0] }}</span>
                    </el-badge>
                    <span v-else>{{ item.split("-")[0] }}</span>
                  </div>
                  <div slot="reference" class="name-wrapper">
                    <span v-if="scope.row.auditState == 0">填报中</span>
                    <span v-else-if="scope.row.auditState == 1">审核中</span>
                    <span v-else-if="scope.row.auditState == 2">审核驳回</span>
                    <span v-else-if="scope.row.auditState == 3">审核完成</span>
                    <span v-else-if="scope.row.auditState == 4">自评中</span>
                    <span v-else-if="scope.row.auditState == 5">他评中</span>
                    <span v-else-if="scope.row.auditState == 6">评价完成</span>
                    <span v-else-if="scope.row.auditState == 7">已完成</span>
                    <span v-else-if="scope.row.auditState == 8">未完成</span>
                  </div>
                </el-popover>
              </template>
            </el-table-column>
            <el-table-column
              prop="stateExplain"
              header-align="center"
              align="center"
              width="140"
              label="任务书状态"
            >
              <template slot-scope="scope">
                <div>
                  <el-popover placement="top" width="660" trigger="hover">
                    <el-table :data="scope.row.gridData" max-height="400">
                      <el-table-column
                        width="260"
                        property="NAME_"
                        label="任务名称"
                        show-overflow-tooltip
                      ></el-table-column>
                      <el-table-column
                        width="120"
                        property="ry_name"
                        label="处理人"
                        show-overflow-tooltip
                      ></el-table-column>
                      <el-table-column
                        width="120"
                        property="START_TIME_"
                        label="开始时间"
                        show-overflow-tooltip
                      ></el-table-column>
                      <el-table-column
                        width="120"
                        property="END_TIME_"
                        label="结束时间"
                        show-overflow-tooltip
                      ></el-table-column>
                    </el-table>
                    <span slot="reference">{{ scope.row.stateExplain }}</span>
                    <el-button
                      type="primary"
                      icon="el-icon-search"
                      @click="showMessage(scope.row.proceid)"
                      >流程跟踪</el-button
                    >
                  </el-popover>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
    </basic-container>
    <el-dialog :visible.sync="prompt" title="提示" width="30%">
      <div>
        <i style="color: #d97135; font-size: 32px" class="el-icon-warning"></i
        ><span style="line-height: 32px">是否直接汇总？</span>
      </div>
      <div style="text-align: right">
        <el-button
          type="primary"
          @click="yesBtn"
          v-loading.fullscreen.lock="fullscreenLoading"
          >是</el-button
        >
        <el-button @click="noBtn">否</el-button>
      </div>
    </el-dialog>
    <UserCommonSelect
      v-if="usercomment"
      ref="usercomment"
      @refreshDataList="getDataList"
      @submitfy="submitfy"
    ></UserCommonSelect>
    <check-user-all
      ref="checkUserAll"
      :multiple="false"
      :roleCode="roleCode"
      @getUserList="getDataList"
    ></check-user-all>
    <sortingPerChooseDialog
      :sortingPerChooseDialogData="sortingPerChooseDialogData"
      @sortingPerChooseDialogChild="sortingPerChooseDialogChild"
    ></sortingPerChooseDialog>
    <el-dialog
      title="任务书导入"
      :visible.sync="importVisible"
      :show-close="false"
    >
      <el-form :model="importForm" ref="importForm" :rules="dataRule">
        <el-row style="display: flex; justify-content: space-between">
          <el-col :span="12" style="margin-top: 20px">
            <el-form-item label="模板名称:" prop="templateId">
              <el-select
                v-model="importForm.templateId"
                placeholder="模板名称"
                class="xiaLa"
                style="width: 80%"
                :clearable="true"
              >
                <el-option
                  v-for="(item, index) in categoryList"
                  :key="index"
                  :label="item.templateName"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col
            :span="12"
            style="display: flex; justify-content: flex-end"
            class="importantBg"
          >
            <el-upload
              ref="upload"
              action=""
              :headers="headers"
              :data="importForm"
              multiple
              :file-list="fileList"
              :before-upload="handleBefore"
              :on-success="handleSuccess"
              :http-request="httpRequest"
              accept=".docx"
            >
              <el-button
                icon="el-icon-upload"
                type="success"
                style="margin-right: 93px"
                >导入任务书文件</el-button
              >
            </el-upload>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          plain
          @click="uploadBtn('importForm')"
          v-loading.fullscreen.lock="fullscreenLoading"
          >保 存</el-button
        >
        <el-button @click="importVisible = false">取 消</el-button>
      </span>
    </el-dialog>
    <processTracking
      ref="processTracking"
      @processTrackingChildren="getDataList"
    ></processTracking>
    <addDialog ref="addDialog" @addChildren="getDataList"></addDialog>
    <editDialog ref="editDialog" @editChildren="getDataList"></editDialog>
  </div>
</template>  

<script>
import UserCommonSelect from "@/views/hetongrenwu/hetong/hetongyeji/hetonghtxxdjb/formulateDialog";
import { getStepInfo, effective } from "@/api/hetongrenwu/hetongyeji/hetongnd";
import UserCommonSelectTask from "@/views/hetongrenwu/components/usercomment-select";
import {
  page,
  deleteBatchHtcj,
  isExistMubiao,
  confirmZbExist,
  Htongndts,
  tuisongwenben,
  faqiqianding,
  exportWord,
} from "@/api/hetongrenwu/book/bookcj";
import processTracking from "./picDialog/processTracking";
import { mapGetters } from "vuex";
import checkUserAll from "@/components/form/compound/selectUser";
import sortingPerChooseDialog from "@/views/hetongrenwu/components/sortingPerChooseDialog.vue";
import store from "@/store";
import addDialog from "./addDialog";
import editDialog from "./editDialog";

export default {
  components: {
    checkUserAll,
    sortingPerChooseDialog,
    UserCommonSelect,
    UserCommonSelectTask,
    addDialog,
    editDialog,
    processTracking,
  },
  data() {
    return {
      dataRule: {
        templateId: [
          { required: true, message: "请选择模板名称", trigger: "change" },
        ],
      },
      categoryList: [],
      importForm: {},
      importVisible: false,
      taskId: "",
      headers: {
        Authorization: "Bearer " + store.getters.access_token,
      },
      dataForm: {
        key: "",
      },
      usercomment: false,
      sortingPerChooseDialogData: {},
      roleCode: "",
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      prompt: false,
      dataListLoading: false,
      fullscreenLoading: false,
      addOrUpdateVisible: false,
      fullscreenLoadingnd: false,
      fullscreenLoadingwb: false,
      mainId: Number,
      ids: [],
      confirmTreeData: [
        {
          id: 5,
          label: "二级机构",
        },
      ],
      selectedTreeData: [],
      searchadvanced: true,
      searchheight: "0",
      sumweight: false,
      sumweightList: [],
      objdata: "",
      text: "",
      jsonData: "",
      isShow: true,
      flag: 0,
      rednermsg: true,
      file: [],
      fileList: [],
    };
  },
  watch: {},
  filters: {
    ellipsis(value) {
      if (!value) return "";
      if (value.length > 8) {
        return value.slice(0, 8) + "...";
      }
      return value;
    },
  },
  created() {
    this.getDataList();
  },
  computed: {
    ...mapGetters(["permissions"]),
  },
  methods: {
    exportWord() {
      exportWord().then((response) => {
        this.$message.closeAll();
        this.$message.success("下载成功!");
        let url = window.URL.createObjectURL(new Blob([response.data]));
        let link = document.createElement("a");
        link.style.display = "none";
        link.href = url;
        link.setAttribute("download", "任务书模板.docx");
        document.body.appendChild(link);
        link.click();
      });
    },
    // 获取下拉
    fneffective() {
      effective({
        tagName: "工作任务书",
      }).then((res) => {
        this.categoryList = res.data.data;
      });
    },
    openImport() {
      this.fileList = [];
      this.file = [];
      this.importForm = {};
      this.importVisible = true;
      this.fneffective();
    },
    httpRequest(param) {
      this.file.push(param.file); // 一般情况下是在这里创建FormData对象，但我们需要上传多个文件，为避免发送多次请求，因此在这里只进行文件的获取，param可以拿到文件上传的所有信息
    },
    handleBefore(file) {
      console.log(file);
      return new Promise((resolve, reject) => {
        var forms = new FormData();
        var configs = {
          headers: {
            "Content-Type": "multipart/form-data",
            Authorization: "Bearer " + store.getters.access_token,
          },
        };
        forms.append("file", file);
        this.axios
          .post("/appr-contract/workassigncj/importRWCheck", forms, configs)
          .then((res) => {
            if (res.data.data != null) {
              this.$message.error(res.data.data);
              return reject(false);
            } else {
              return resolve(true);
            }
          });
      });
    },
    uploadBtn(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.fullscreenLoading = true;
          var upData = new FormData();
          upData.append("templateId", this.importForm.templateId);
          setTimeout(() => {
            this.file.forEach(function (file) {
              // 因为要上传多个文件，所以需要遍历
              upData.append("file", file, file.name);
            });
            this.axios
              .post("/appr-contract/workassigncj/importRW", upData)
              .then((res) => {
                this.importVisible = false;
                this.$message.success("导入成功");
                this.getDataList();
                this.fullscreenLoading = false;
              })
              .catch(function (error) {
                console.log(error);
                this.fullscreenLoading = false;
              });
          }, 9000);
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    handleSuccess() {
      this.importVisible = false;
      this.$message.success("导入成功");
      this.getDataList();
    },
    showMessage(proId) {
      this.$refs.processTracking.init(proId);
    },
    submitfy(data) {
      var params = {
        flag: "否",
        rows: JSON.stringify(this.$refs.table.selection),
        selectdata: JSON.stringify(data.tableDataUser),
        selectorgdata: JSON.stringify(data.selectorgdata),
        bkhr: data.bkhr,
      };
      Htongndts(params).then((res) => {
        this.$message.closeAll();
        this.$message.success("拟定推送成功");
        this.prompt = false;
        this.getDataList();
      });
    },
    addUser(type) {
      this.usercomment = true;
      this.jsonData = JSON.stringify(this.ids);
      this.$nextTick(() => {
        this.$refs.usercomment.init("12", type, this.jsonData, "rwsndts");
      });
    },
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "50";
      }
    },
    //获取合同列表
    getDataList() {
      this.dataListLoading = true;
      page(
        Object.assign(
          {
            current: this.pageIndex,
            size: this.pageSize,
          },
          this.dataForm
        )
      ).then((response) => {
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
        this.dataListLoading = false;
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    // 新增
    addOrUpdateHandle() {
      this.$refs.addDialog.init();
    },
    // 编辑
    editBtn(row) {
      this.$refs.editDialog.init(row);
    },
    //确定选择选中得机构
    fnConfirmSelectedData() {
      this.confirmTreeData = this.selectedTreeData;
    },
    //树结构选中的数据
    handleCheckChange(data) {
      var index = this.selectedTreeData.findIndex(
        (item) => item.deptId == data.deptId
      );
      if (index == -1) {
        this.selectedTreeData.push(data);
      } else {
        this.selectedTreeData.splice(index, 1);
      }
    },
    //
    getHtWeight() {
      var data = this.$refs.table.selection;
      for (var i = 0; i < data.length; i++) {
        if (data[i].state != 5 && data[i].state != 8 && data[i].state != 11) {
          this.$message.warning(
            "请选择汇总完成、文本审核驳回和被考核人驳回的数据"
          );
          return;
        }
      }
      var params = {
        rows: data,
      };
      this.fullscreenLoadingwb = true;
      tuisongwenben(params)
        .then((res) => {
          this.$message.closeAll();
          this.$message.success("推送成功");
          this.fullscreenLoadingwb = false;
          this.getDataList();
        })
        .catch((res) => {
          this.fullscreenLoadingwb = false;
        });
    },
    sortingPerChooseDialogChild(data) {
      this.getDataList();
    },
    //拟定推送-外面
    ndts() {
      this.ids = [];
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      var mainId = "";
      var ids = [];
      for (var i = 0; i < data.length; i++) {
        ids.push(data[i].id);
        mainId = data[i].templateId;
        if (data[i].state != 0) {
          this.$message.warning("请勾选创建中的数据");
          return;
        }
      }
      this.ids = ids;
      var params = {
        ids: ids,
      };
      var params2 = {
        stepName: "指标拟定",
        mainId: mainId,
      };

      // 判断是否有指标，有指标提示是否直接汇总，没有指标直接弹出窗口选人
      confirmZbExist(params).then((res) => {
        if (res.data.data) {
          isExistMubiao(params).then((response) => {
            if (response.data.data) {
              this.fullscreenLoadingnd = true;
              // 判断是否有模板名称
              if (params2.mainId) {
                getStepInfo(params2).then((result) => {
                  var flagtext = "";
                  if (result.data.data.isjump == "true") {
                    flagtext = "是";
                    Htongndts({
                      rows: JSON.stringify(this.$refs.table.selection),
                      flag: flagtext,
                    }).then((con) => {
                      this.$message.closeAll();
                      this.$message.success("拟定推送成功");
                      this.getDataList();
                      this.fullscreenLoadingnd = false;
                    });
                  } else {
                    this.fullscreenLoadingnd = false;
                    (flagtext = "否"), this.noBtn();
                  }
                });
              } else {
                this.prompt = true;
                this.fullscreenLoadingnd = false;
              }
            } else {
              this.$confirm(
                "选中数据存在指标目标值为空或者权重值为空的情况，是否继续提交",
                "提示",
                {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                }
              ).then(() => {
                // 判断是否有模板名称
                if (params2.mainId) {
                  this.fullscreenLoadingnd = true;
                  getStepInfo(params2).then((result) => {
                    var flagtext = "";
                    if (result.data.data.isjump == "true") {
                      flagtext = "是";
                      Htongndts({
                        rows: JSON.stringify(this.$refs.table.selection),
                        flag: flagtext,
                      }).then((con) => {
                        this.$message.closeAll();
                        this.$message.success("拟定推送成功");
                        this.getDataList();
                        this.fullscreenLoadingnd = false;
                      });
                    } else {
                      this.fullscreenLoadingnd = false;
                      (flagtext = "否"), this.noBtn();
                    }
                  });
                } else {
                  this.prompt = true;
                }
              });
            }
          });
        } else {
          this.prompt = false;
          this.addUser("ndts");
        }
      });
    },
    yesBtn() {
      this.fullscreenLoading = true;
      var params = {
        flag: "是",
        rows: JSON.stringify(this.$refs.table.selection),
      };
      Htongndts(params).then((res) => {
        this.fullscreenLoading = false;
        this.$message.closeAll();
        this.$message.success("拟定推送成功");
        this.prompt = false;
        this.getDataList();
      });
    },
    noBtn() {
      this.prompt = false;
      this.addUser("rwsndts");
    },
    fszbbumen() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      if (data[0].contractAuditStatus != 0) {
        this.$message.closeAll();
        this.$message.error("请选择创建中的合同！");
        return;
      }
      this.zbvisible = true;
    },
    //拟定推送-里面
    ts() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      if (data.length > 1) {
        this.$message.closeAll();
        this.$message.error("只能选择一个合同！");
        return;
      }
      if (data[0].contractAuditStatus != 0) {
        this.$message.closeAll();
        this.$message.error("请选择创建中的合同！");
        return;
      }
      var ids = this.selectedTreeData.map((item) => {
        return item.deptId;
      });
      if (data[0].quotaauditStatusstr == "未填报") {
        this.$confirm("是否直接汇总？", "提示", {
          confirmButtonText: "是",
          cancelButtonText: "否",
          type: "warning",
        })
          .then((data) => {
            this.$message.closeAll();
            this.$message.success("拟定推送成功");
            this.getDataList();
          })
          .catch(() => {});
        // this.zbvisible=true;
      }
    },
    deleteBatch() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请至少选择一个合同！");
        return;
      }
      var ids = [];
      for (var i = 0; i < data.length; i++) {
        ids.push(data[i].id);
        if (data[i].stateExplain != "创建中") {
          this.$message.closeAll();
          this.$message.warning("只能删除创建中的数据");
          return;
        }
      }
      var idsStr = ids.join(",");
      this.$confirm("是否要删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return deleteBatchHtcj({ ids: idsStr });
        })
        .then((data) => {
          this.$message.closeAll();
          this.$message.success("删除成功");
          this.getDataList();
        });
    },
    cutout(cellValue) {
      if (cellValue) {
        var c = cellValue.split(",");
        if (c.size < 1) {
          c.push("-");
          c.push("-");
        } else if (c.size < 2) {
          c.push("-");
        }
        return c;
      }
    },
    FqqdBtn() {
      var data = this.$refs.table.selection;
      for (var i = 0; i < data.length; i++) {
        if (data[i].state != 9) {
          this.$message.warning("请选择汇总完成和文本审核驳回的数据");
          return;
        }
      }
      this.fullscreenLoadingwb = true;
      faqiqianding({ rows: data }).then((res) => {
        this.$message.success("发起签订成功");
        this.fullscreenLoadingwb = false;
        this.getDataList();
      });
    },
    print() {},
  },
};
</script>
<style>
.icon-box i {
  margin: 0 8px;
  color: #028ae2;
}

.el-tooltip__popper {
  max-width: 80%;
}

.itembadge {
  margin-top: 10px;
  margin-right: 0px;
}
.inline-block {
  display: inline-block;
}
.bg .el-image-viewer__mask {
  background-color: white;
  opacity: 1;
}
</style>
<style>
.importantBg {
  width: 45%;
  border-radius: 16px;
  padding: 10px;
  box-shadow: 4px 4px 6px #888888;
  background: #fff;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
}
.importantBg .el-upload-list {
  overflow-y: scroll;
  height: 150px;
}
</style>

